﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using MezmurStore2.Models;

namespace MezmurStore2
{
    public class SampleData : DropCreateDatabaseAlways<MezmurStoreEntities>
    {
        protected override void Seed(MezmurStoreEntities context)
        {
            var artists = new List<Artist>
            {
                new Artist { Name = "Mirtnesh", Id = Guid.NewGuid() },
                new Artist { Name = "Zerfe", Id = Guid.NewGuid()  },
                new Artist { Name = "Dn. Tizitaw", Id = Guid.NewGuid()  },
                new Artist { Name = "Dn. Yilma", Id = Guid.NewGuid()  },
                new Artist { Name = "Dn. Endalkachew", Id = Guid.NewGuid()  }
            };
            artists.ForEach(a => context.Artists.Add(a));
            
            var tracks = new List<Track>
            {       new Track(){Name = "Track 1", Id = Guid.NewGuid(), FilePath = @"media\Tizitaw\01_Tizitaw.mp3", FileSize = 1230554, Artist= artists.First(a => a.Name == "Dn. Tizitaw")}, 
                    new Track(){Name = "Track 2", Id = Guid.NewGuid(), FilePath = @"media\Tizitaw\02_Tizitaw.mp3", FileSize = 9230554, Artist= artists.First(a => a.Name == "Dn. Tizitaw")}, 
                    new Track(){Name = "Track 3", Id = Guid.NewGuid(), FilePath = @"media\Tizitaw\03_Tizitaw.mp3",FileSize = 8030554, Artist= artists.First(a => a.Name == "Dn. Tizitaw")}, 
                    new Track(){Name = "Track 1", Id = Guid.NewGuid(), FilePath = @"media\Yilma\01_Yilma.mp3", FileSize = 30554, Artist= artists.First(a => a.Name == "Dn. Yilma")}, 
                    new Track(){Name = "Track 2", Id = Guid.NewGuid(), FilePath = @"media\Yilma\02_Yilma.mp3", FileSize = 230554, Artist= artists.First(a => a.Name == "Dn. Yilma")},
            };
            tracks.ForEach(t => context.Tracks.Add(t));

            var albums =  new List<Album>
            {
                new Album {Id = Guid.NewGuid(), Title = "Selame Bantenew", Gener = "Misgana", Poster = @"media\tizitaw\tumbnail.jpg", ReleaseDate = new DateTime(2001, 9, 11), Tracks = tracks.FindAll(t=>t.FilePath.Contains("Tizitaw"))},

                new Album {Id = Guid.NewGuid(), Title = "Ete Mushiraye", Gener = "Misgana", Poster = @"media\Yilma\tumbnail.jpg", ReleaseDate = new DateTime(2001, 9, 11), Tracks = tracks.FindAll(t=>t.FilePath.Contains("Yilma"))},

            };
            albums.ForEach(a => context.Albums.Add(a));
        }
    }
}